package com.ns.dcjh.listener;

import com.ns.dcjh.utils.BlockUtils;
import com.orhanobut.logger.Logger;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;


public class MyUMShareListener implements UMShareListener {
    private BlockUtils onSuccess;
    private BlockUtils onError;

    @Override
    public void onStart(SHARE_MEDIA share_media) {

    }

    @Override
    public void onResult(SHARE_MEDIA share_media) {
        Logger.d(String.format("分享 %s 成功", share_media.getName()));
        if (onSuccess == null)  return;
        onSuccess.callbackWithBoolean(true,null);
    }

    @Override
    public void onError(SHARE_MEDIA share_media, Throwable throwable) {
        Logger.d(String.format("分享 %s 错误", share_media.getName()));
        if (onError == null)  return;
        onError.callbackWithBoolean(false, throwable.getMessage());
    }

    @Override
    public void onCancel(SHARE_MEDIA share_media) {

    }

    public void setOnSuccess(BlockUtils onSuccess) {
        this.onSuccess = onSuccess;
    }

    public void setOnError(BlockUtils onError) {
        this.onError = onError;
    }

    public BlockUtils getOnSuccess() {
        return onSuccess;
    }

    public BlockUtils getOnError() {
        return onError;
    }
}
